#include <sys/timerfd.h>
#include <iostream>
#include <sys/epoll.h>
#include <errno.h>
#include <vector>


using namespace std;

int createTimerfd()
{
	int timerfd = ::timerfd_create(CLOCK_MONOTONIC,
		TFD_NONBLOCK|TFD_CLOEXEC);
	if(timerfd < 0)
	{
		cout<<"Failed in timefd_create";
	}
	return timerfd;
}

const int timeoutMS = 10000;

int main()
{
	int epollfd = ::epoll_create1(EPOLL_CLOEXEC);
	int timefd = createTimerfd();
	struct epoll_event event;
	bzero(&event, sizeof event);
	event.events = EPOLLIN;
	event.data.fd = timefd;

	::epoll_ctl(epollfd, EPOLL_CTL_ADD, 
			timefd, &event);

	vector<struct epoll_event> event_list;
	int numEvents = ::epoll_wait(epollfd,
			&*event_list.begin(),
			static_cast<int>(event_list.size()),
			timeoutMS);
	for(int i = 0 ; i < numEvents; ++i)
	{
		int fd = event_list[i].data.fd;

	}
}
